package com.baiye.template.common;

import lombok.Data;

/**
 * @author GUOZHIPENG
 * @version 1.0
 * @date 2021/8/26 16:12
 */
@Data
public class R<T> {
    private boolean success;
    private Integer code;
    private T data;
    private String token;
    private String msg;
    public R ok(T data){
        this.success=true;
        this.setCode(200);
        this.data=data;
        return this;
    }
    public R login(T data,String token){
        this.success=true;
        this.setCode(200);
        this.data=data;
        this.token=token;
        return this;
    }
    public R ok(){
        this.success=true;
        this.setCode(200);
        return this;
    }
    public R ok(T data,String msg){
        this.success=true;
        this.setCode(200);
        this.data=data;
        this.msg=msg;
        return this;
    }
    public R error(T data,String msg){
        this.success=false;
        this.setCode(500);
        this.data=data;
        this.msg=msg;
        return this;
    }
    public R error(Integer code,String msg){
        this.success=false;
        this.setCode(code);
        this.msg=msg;
        return this;
    }
    public R error(String msg){
        this.success=false;
        this.setCode(500);
        this.msg=msg;
        return this;
    }


}
